# How to use :
# docker build -t expm02/docker-trojan --build-arg password=demo_password .
# --------------------------------------------------------------------------------

FROM alpine:3.11
ARG password=demo_password

COPY . trojan
RUN apk add --no-cache --virtual .build-deps \
        build-base \
        cmake \
        boost-dev \
        openssl-dev \
        mariadb-connector-c-dev \
    && (cd trojan && cmake . && make -j $(nproc) && strip -s trojan \
    && mv trojan /usr/local/bin) \
    && rm -rf trojan \
    && apk del .build-deps \
    && apk add --no-cache --virtual .trojan-rundeps \
        libstdc++ \
        boost-system \
        boost-program_options \
        mariadb-connector-c

RUN  mkdir -p /usr/local/etc/trojan/cert/

ADD ./etc/config.json /usr/local/etc/trojan/config.json
RUN sed -i "s/YOUR_PASSWORD/${password}/g" /usr/local/etc/trojan/config.json

EXPOSE 443
WORKDIR /usr/local/etc/trojan/
CMD [ "trojan", "/usr/local/etc/trojan/config.json" ]